package controller.auth;

import java.util.HashMap;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import service.auth.UsersService;
import core.base.controller.BaseSpringController;

@Controller("admin.auth.UsersAdminController")
@RequestMapping("/admin/auth/users")
public class UsersAdminController extends BaseSpringController {
	private String queryView = "admin/users/query";
	private String incListView = "admin/users/inclist";
	private String addView = "admin/users/resadd";
	private String viewView = "admin/users/resview";
	private String redirectView = "admin/common/redirect";

	@Autowired
	@Qualifier("auth.UsersService")
	private UsersService usersService;

	@RequestMapping("query.htm")
	public ModelAndView query(HttpServletRequest request, HttpServletResponse response) {
		return new ModelAndView(queryView);
	}

	@RequestMapping("inc_list.htm")
	public ModelAndView incList(HttpServletRequest request, HttpServletResponse response) {

		return new ModelAndView(incListView);
	}

	@RequestMapping("add.htm")
	public ModelAndView add(HttpServletRequest request, HttpServletResponse response) {
		Map<String, Object> modelMap = new HashMap<String, Object>();
		return new ModelAndView(addView).addAllObjects(modelMap);
	}

	@RequestMapping("addsave.htm")
	public ModelAndView addSave(HttpServletRequest request, HttpServletResponse response) {
		String redirecturl = request.getContextPath() + "/admin/auth/users/query.htm";
		return new ModelAndView(redirectView).addObject("redirecturl", redirecturl);
	}

	@RequestMapping("delbatch.htm")
	public ModelAndView delbatch(HttpServletRequest request, HttpServletResponse response) {

		return new ModelAndView(redirectView);
	}

	@RequestMapping("view.htm")
	public ModelAndView view(HttpServletRequest request, HttpServletResponse response) {
		Map<String, Object> modelMap = new HashMap<String, Object>();
		Long id = Long.valueOf(request.getParameter("id"));

		return new ModelAndView(viewView).addAllObjects(modelMap);
	}

	public void setUsersService(UsersService usersService) {
		this.usersService = usersService;
	}

}
